package kernel;
/**
 * 
 * @author Chris Ren
 * 		   Aaron Fung
 *
 */

/**
 * Timer that generates an interrupt to the CPU once a while.
 */
public class CPUTimer extends Thread
{
	/**
	 * the CPU the timer is associated to .
	 */
	final CPU my_cpu;
	
	public CPUTimer(final CPU the_cpu)
	{
		my_cpu = the_cpu;
	}
	
	/**
	 * stop for every 10 sec and generates a timer interrupt to the CPU.
	 */
	@Override
	public void run()
	{
		while(true)
		{
			System.out.print("");
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
			my_cpu.contextSwitch(CPU.Request.TIMER_REQUEST);
		}
	}
}
